package com.zw.goods.controller;


import com.zw.commons.log.annotation.Log;
import com.zw.commons.log.enums.BusinessType;
import com.zw.goods.service.GoodStockService;
import com.zw.goods.service.GoodTypeService;
import com.zw.object.goods.GoodType;
import com.zw.object.result.Result;
import com.zw.object.vo.GoodsAllTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 物资类型表 前端控制器
 * </p>
 *
 * @author zw
 * @since 2023-03-15
 */
@Api(tags = "物资类型")
@RestController
@RequestMapping("/goods/good-type")
public class GoodTypeController {
    @Autowired
    private GoodTypeService goodTypeService;


    @Log(title = "简单查询物资类型",businessType = BusinessType.SELECT)
    @ApiOperation("简单查询物资类型")
    @GetMapping("/simple")
    public Result simple(){
        return goodTypeService.simple();
    }

    @PostMapping("/list")
    @ApiOperation("全部的物资类型查询")
    @Log(title = "全部物资类型查询",businessType = BusinessType.SELECT)
    public Result goodsTypeList(@Validated @RequestBody GoodsAllTypeVo vo){
        return goodTypeService.goodsTypeList(vo);
    }

    @PostMapping("/save")
    @Log(title = "物资类别添加",businessType = BusinessType.INSERT)
    @ApiOperation("物资类别添加")
    public Result save(@Validated @RequestBody GoodType goodType, HttpServletRequest request){
        return goodTypeService.save(goodType,request);
    }

    @PostMapping("/update")
    @ApiOperation("更新物资信息")
    @Log(title = "跟新物资信息",businessType = BusinessType.UPDATE)
    public Result update(@Validated @RequestBody GoodType goodType, HttpServletRequest request){
        return goodTypeService.update(goodType,request);
    }

    @PostMapping("/delete")
    @ApiOperation("删除物资信息")
    @Log(title = "删除物资信息",businessType = BusinessType.DELETE)
    public Result delete(@RequestBody @RequestParam("ids") Long[] ids){
        return goodTypeService.delete(ids);
    }


}

